{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "f04dd603-a2d1-48ce-8c17-9f1dba8de1ee",
   "metadata": {},
   "source": [
    "Chapter 01\n",
    "\n",
    "# 三角形法则\n",
    "《线性代数》 | 鸢尾花书：数学不难"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ccafb456-2453-4c82-8a65-b1963a370cb2",
   "metadata": {},
   "source": [
    "这段代码的数学核心是**向量的加法及其几何可视化**，通过绘制向量的箭头图形来展示向量的几何和代数性质。  \n",
    "\n",
    "---\n",
    "\n",
    "### **向量的定义与加法**\n",
    "代码首先定义了两个二维向量：\n",
    "\n",
    "$$\n",
    "\\mathbf{a} = \\begin{bmatrix} 4 \\\\ 1 \\end{bmatrix}, \\quad \\mathbf{b} = \\begin{bmatrix} 1 \\\\ 2 \\end{bmatrix}\n",
    "$$\n",
    "\n",
    "然后计算它们的**向量和**：\n",
    "\n",
    "$$\n",
    "\\mathbf{a} + \\mathbf{b} = \\begin{bmatrix} 4 \\\\ 1 \\end{bmatrix} + \\begin{bmatrix} 1 \\\\ 2 \\end{bmatrix} = \\begin{bmatrix} 4 + 1 \\\\ 1 + 2 \\end{bmatrix} = \\begin{bmatrix} 5 \\\\ 3 \\end{bmatrix}\n",
    "$$\n",
    "\n",
    "向量加法的几何意义是：  \n",
    "- 先从原点出发绘制 $\\mathbf{a}$，到达终点 $(4,1)$；  \n",
    "- 再从该点出发绘制 $\\mathbf{b}$，最终到达 $(5,3)$；  \n",
    "- 直接连接原点 $(0,0)$ 和终点 $(5,3)$，得到和向量 $\\mathbf{a} + \\mathbf{b}$。  \n",
    "\n",
    "这种方法称为**向量加法的三角形法则**，因为三个点 $(0,0)$、$(4,1)$ 和 $(5,3)$ 形成了一个**三角形**。\n",
    "\n",
    "---\n",
    "\n",
    "### **可视化**\n",
    "代码使用 `matplotlib.pyplot.quiver` 进行向量绘制，以下是绘图细节：\n",
    "\n",
    "1. **绘制向量 $\\mathbf{a}$**\n",
    "   - 起点设为 $(0,0)$，终点设为 $(4,1)$，颜色设为红色。\n",
    "\n",
    "2. **绘制向量 $\\mathbf{b}$**（**平移到 $\\mathbf{a}$ 的终点**）\n",
    "   - 起点设为 $\\mathbf{a}$ 的终点 $(4,1)$，终点设为 $(5,3)$，颜色设为蓝色。\n",
    "\n",
    "3. **绘制向量 $\\mathbf{a} + \\mathbf{b}$**\n",
    "   - 直接从原点 $(0,0)$ 绘制到最终结果 $(5,3)$，颜色设为粉色。\n",
    "\n",
    "4. **坐标系与美观调整**\n",
    "   - 设定坐标范围 $x \\in [0,5]$，$y \\in [0,5]$，以便所有向量可视化。\n",
    "   - 添加 $x$ 轴和 $y$ 轴，保证绘制的直观性。\n",
    "   - 启用网格，增强视觉参考。\n",
    "   - 使用 `plt.legend()` 添加图例，标注每个向量的含义。\n",
    "\n",
    "---\n",
    "\n",
    "### **几何解释**\n",
    "代码本质上展示了**向量加法的三角形法则**，即：\n",
    "\n",
    "$$\n",
    "\\mathbf{a} + \\mathbf{b} = \\mathbf{c}\n",
    "$$\n",
    "\n",
    "其中，$\\mathbf{c}$ 是从原点 $(0,0)$ 到最终点 $(5,3)$ 的向量，且向量 $\\mathbf{a}$ 和 $\\mathbf{b}$ 首尾相接，形成一个三角形：\n",
    "\n",
    "- 三角形的 **一条边** 是 $\\mathbf{a}$，起点 $(0,0)$，终点 $(4,1)$；\n",
    "- 三角形的 **第二条边** 是 $\\mathbf{b}$，起点 $(4,1)$，终点 $(5,3)$；\n",
    "- 三角形的 **第三条边** 是 $\\mathbf{a} + \\mathbf{b}$，连接 $(0,0)$ 和 $(5,3)$。\n",
    "\n",
    "这个法则表明**向量的加法可以用三角形来表示**，即：  \n",
    "**从一个点出发，连续沿着两个向量方向移动，最终到达的点就是它们的和。**\n",
    "\n",
    "---\n",
    "\n",
    "### **总结**\n",
    "- **代数上**，向量加法是分量相加的运算；\n",
    "- **几何上**，向量加法遵循**三角形法则**，即两个向量首尾相接，结果向量从起点到终点；\n",
    "- **代码实现**了向量加法的几何可视化，使得数学概念更加直观。\n",
    "\n",
    "这段代码对于学习线性代数中的**向量运算**和**几何解释**非常有帮助，是二维向量加法的一个基本案例。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7ad0b66c-609f-443f-9671-e91d35958948",
   "metadata": {},
   "source": [
    "## 初始化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "13f24a5f-0c2c-4c26-8ca5-5d02f8e0789c",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cfba2da9-2eaf-4918-bfcf-a377bd40a14b",
   "metadata": {},
   "source": [
    "## 定义向量"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "de6e27fe-ecc8-4a8f-9759-5582621c59de",
   "metadata": {},
   "outputs": [],
   "source": [
    "a_vec = np.array([4, 1])\n",
    "b_vec = np.array([1, 2])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6995e14b-57a2-4d6a-9eb7-b30b78337cf2",
   "metadata": {},
   "source": [
    "## 计算向量和"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "45e229b8-0d2f-471d-b3b3-a7318aaf56dd",
   "metadata": {},
   "outputs": [],
   "source": [
    "a_plus_b = a_vec + b_vec"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2847be99-994b-4013-ab7b-f09d4e9b5b0b",
   "metadata": {},
   "source": [
    "## 可视化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "439bd53d-4ad2-4219-9e2e-8196eb9e5857",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.legend.Legend at 0x26cb89cfa40>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAfkAAAH/CAYAAABU76T5AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90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VqzQjh07CL0NTp48qQceeEB/+ctfNHLkSLePEwiLFi3q/ucZM2aovLxckydP1q9//eteH98+HEciH89H1AJ+tHr1ar3++uvauXOnxo8f7/ZxjJaenq4pU6ZIkmbPnq2amho988wz2rBhg8snM8/evXt15swZzZo1q/t77e3t2rlzp5599llFIhGlpqa6eELzZWVlacaMGTp8+LCl2znynDwfUQvTRaNR3X///frDH/6gN998U6WlpW4fKXCi0agikYjbxzDSzTffrP3792vfvn3dX7Nnz9by5cu1b98+Au+ASCSiQ4cOqaioyNLtHFvX8xG1zvrss8905MiR7svHjh3Tvn37lJ+frwkTJrh4MjOtWrVKL730kl577TVlZ2d3b61yc3OVmZnp8unM8+ijj2rRokUqKSnR+fPnVVVVpe3bt6u6utrtoxkpOzu73+tLsrKyVFBQwOtObPLwww9r8eLFmjBhgs6cOaMnnnhCTU1NWrFihaXf41jkE/2IWlizZ88e3Xjjjd2Xu57DWbFihV588UWXTmWu9evXS5Lmz5/f6/svvPCC7r33XucPZLjTp0/rnnvuUV1dnXJzc1VWVqbq6mrdcsstbh8NSIqPPvpId911l86ePavLL79c1157rXbv3m25mXzULAAAhuK96wEAMBSRBwDAUEQeAABDEXkAAAxF5AEAMBSRBwDAUEQeAABDEXkAAAxF5AEAMBSRBwDAUEQeAABDEXkAAAz1/wGVt72jrFmjQQAAAABJRU5ErkJggg==",
      "text/plain": [
       "<Figure size 600x600 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(6,6))\n",
    "\n",
    "# 绘制向量 a\n",
    "plt.quiver(0, 0, \n",
    "           a_vec[0], a_vec[1], \n",
    "           angles='xy', scale_units='xy', scale=1, \n",
    "           color='r', label=\"a\")\n",
    "\n",
    "# 绘制向量 b，b的起点移动到a终点\n",
    "plt.quiver(a_vec[0], a_vec[1], \n",
    "           b_vec[0], b_vec[1], \n",
    "           angles='xy', scale_units='xy', scale=1, \n",
    "           color='b', label=\"a\")\n",
    "\n",
    "# 绘制向量 a + b\n",
    "plt.quiver(0, 0, \n",
    "           a_plus_b[0], a_plus_b[1], \n",
    "           angles='xy', scale_units='xy', scale=1, \n",
    "           color='pink', label=\"a + b\")\n",
    "\n",
    "# 装饰\n",
    "plt.gca().set_aspect('equal', adjustable='box')\n",
    "plt.xlim(0, 5)  # 设置 x 轴范围\n",
    "plt.ylim(0, 5)  # 设置 y 轴范围\n",
    "plt.axhline(0, color='black', linewidth=0.5)\n",
    "plt.axvline(0, color='black', linewidth=0.5)\n",
    "plt.grid(color='gray', alpha=0.8, linestyle='-', linewidth=0.25) \n",
    "\n",
    "plt.legend() # 添加图例"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "aa20a6ee-9716-4231-95c0-6b683863c337",
   "metadata": {},
   "source": [
    "作者\t**生姜DrGinger**  \n",
    "脚本\t**生姜DrGinger**  \n",
    "视频\t**崔崔CuiCui**  \n",
    "开源资源\t[**GitHub**](https://github.com/Visualize-ML)  \n",
    "平台\t[**油管**](https://www.youtube.com/@DrGinger_Jiang)\t\t\n",
    "\t\t[**iris小课堂**](https://space.bilibili.com/3546865719052873)\t\t\n",
    "\t\t[**生姜DrGinger**](https://space.bilibili.com/513194466)  "
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [conda env:base] *",
   "language": "python",
   "name": "conda-base-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
